//
//  MyAccountHeaderView.m
//  Kjs
//
//  Created by cfq on 16/4/19.
//  Copyright © 2016年 kjs. All rights reserved.
//

#import "MyAccountHeaderView.h"
#import "UIImage+MapUIImage.h"

@interface MyAccountHeaderView()
@property (nonatomic,strong) IBOutlet UIView *contantV;
@end

@implementation MyAccountHeaderView
- (void)awakeFromNib {
    self.contantV.layer.cornerRadius = self.contantV.frame.size.height/2;
    self.contantV.layer.masksToBounds = NO;
    //虚线边框
    CAShapeLayer *contantVBorderLayer = [CAShapeLayer layer];
    contantVBorderLayer.bounds = CGRectMake(0, 0, self.contantV.frame.size.width, self.contantV.frame.size.height);
    contantVBorderLayer.position = CGPointMake(CGRectGetMidX(self.contantV.bounds), CGRectGetMidY(self.contantV.bounds));
    contantVBorderLayer.path = [UIBezierPath bezierPathWithRoundedRect:contantVBorderLayer.bounds cornerRadius:CGRectGetWidth(contantVBorderLayer.bounds)/2].CGPath;
    contantVBorderLayer.lineWidth = 1. / [[UIScreen mainScreen] scale];
    contantVBorderLayer.lineDashPattern = nil;
    contantVBorderLayer.fillColor = [UIColor clearColor].CGColor;
    contantVBorderLayer.strokeColor = [UIColor whiteColor].CGColor;
    [self.contantV.layer addSublayer:contantVBorderLayer];
    
    self.allAssets.adjustsFontSizeToFitWidth = YES;
    self.enableAssets.adjustsFontSizeToFitWidth = YES;
    self.frozeAssets.adjustsFontSizeToFitWidth = YES;
    self.userNameLab.adjustsFontSizeToFitWidth = YES;
}

-(void)setUserAssets:(UserAssets *)userAssets
{
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    NSString *allAssetsStr = [formatter stringFromNumber:[NSNumber numberWithDouble:userAssets.totalAssets]];
    NSString *enableAssetsStr = [formatter stringFromNumber:[NSNumber numberWithDouble:userAssets.availablebalance]];
    NSString *frozeAssetStr = [formatter stringFromNumber:[NSNumber numberWithDouble:userAssets.blockedBalance]];
    self.allAssets.text = [NSString stringWithFormat:@"¥%@",allAssetsStr];
    self.enableAssets.text = [NSString stringWithFormat:@"¥%@",enableAssetsStr];
    self.frozeAssets.text = [NSString stringWithFormat:@"¥%@",frozeAssetStr];
    
}

-(void)setNickName:(NSString *)nickName
{
    NSLog(@"nickename=%@",nickName);
    if (nickName) {
        self.userNameLab.text = [NSString stringWithFormat:@"%@，您好！",nickName];
    }else{
        self.userNameLab.text = @"未登录";

    }
}

@end
